import wx
import time

# 自定义窗体类继承wx.Frame
class MyFrame(wx.Frame):
    def change_time(self, event):
        print('修改时间')
        str1 = time.strftime("%Y-%m-%d", time.localtime())
        self.text1.SetLabelText(str1)
        str2 = time.strftime("%H:%M:%S", time.localtime())
        self.text2.SetLabelText(str2)

    def __init__(self):
        # window = wx.Frame(None, title='我的第一个窗体应用', size=(800, 600))
        super().__init__(None, title='我的第一个窗体应用', size=(800, 600))
        # 面板
        panel = wx.Panel(self)
        # 文本
        self.text1 = wx.StaticText(panel, label = '2025-05-20')
        self.text2 = wx.StaticText(panel, label = '09:30:00', pos = (70, 0))
        # 按钮
        btn = wx.Button(panel, label = '点击我修改时间', pos = (0, 50))
        # 事件绑定
        self.Bind(wx.EVT_BUTTON, self.change_time, btn)

app = wx.App()
window = MyFrame()
window.Show()

app.MainLoop()